//
//  GlobalVar.m
//  MyShoes
//
//  Created by mac on 11-7-4.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import "GlobalVar.h"

@implementation GlobalVar


+(NSString *)getFilePath:(NSString *)filename
{
	NSArray *paths=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES);
	NSString *documentDirectory=[paths objectAtIndex:0];
	NSString *filePath=[documentDirectory stringByAppendingPathComponent:filename];
    NSLog(@"%@",filePath);
	return filePath;
}


+(NSString *)createApiUrlAddress:(NSString *)baseUrl
{
    NSMutableString *url = [NSMutableString stringWithString:@"http://"];
    [url appendString:[GlobalVar getDataForKey:@"config.domain"]];
    [url appendString:@":"];
    [url appendString:[GlobalVar getDataForKey:@"config.port"]];
    [url appendString:@"/"];
    [url appendString:baseUrl];
    
    NSLog(@"%@",url);
    return url;
}

+(void)removeData:(NSString *)key
{
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
	[defaults removeObjectForKey:key];
	[defaults synchronize];
}

+(void)saveData:(id)array forKey:(NSString *)key
{
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
	[defaults setObject:array forKey:key];
	[defaults synchronize];
}

+(id)getDataForKey:(NSString *)key
{
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    return [defaults objectForKey:key];
}



@end
